home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d7 / lib231.arc / SALT.DOC < prev    next >
Text File  |  1990-05-11  |  28KB  |  569 lines

  1.  
  2.  
  3.  
  4.                SALT.DOC Copyright (C) 1990 Liberation Enterprises.
  5.                    An introduction to Telix's script language.
  6.  
  7.  
  8.      This is not a comprehensive SALT tutor, and if you are seeking such you
  9.      won't find it here (a more extensive tutor will most likely be released
  10.      in the future).  If you understand the logon scripts provided with
  11.      Telix, then you will probably be wasting your time reading this.  This
  12.      document was designed for beginners, and simply explains some basics of
  13.      SALT, and some easy-to-use but useful functions.  Everything is
  14.      explained in simple terms, to enable non-programmers or new Telix users
  15.      to write usable scripts.  You will also be shown how to make use of the
  16.      dreaded SALT manual.
  17.  
  18.      Learning SALT is usually the only major obstacle people run into with
  19.      Telix.  As I'm sure you are aware, SALT is one of, if not *the* most
  20.      powerful 'script' language available for any communications program. 
  21.      Unfortunately, extra power usually translates into a more involved
  22.      learning process--the more power (or features) you have, the more there
  23.      is to learn.  However, you need not learn the entire language and study
  24.      the entire SALT manual to create useful scripts.  There are a few SALT
  25.      statements and functions listed below, that will enable you to automate
  26.      fairly complex tasks, without getting into any major programming.  The
  27.      functions are:
  28.  
  29.      capture();     Open, close, or pause a capture file.  Specify the name
  30.                     of the capture file between double quotes (e.g.
  31.                     capture("TELIX.CAP").  If you don't specify a path,
  32.                     Telix creates the file in the same directory as
  33.                     TELIX.EXE.  See CAPCMD.SLT for example usage of
  34.                     capture().
  35.      cputs();       Put a 'string' of text out the communications port
  36.                     (cputs is 'c' for communications port (modem), 'put'
  37.                     for... put, 's' for string.  A string is just a bunch of
  38.                     characters grouped together between double quotes; a
  39.                     sentence (e.g. "This is a string").
  40.      delay_scr();   Pause the script from running for a certain amount of
  41.                     time.  This is similar to delay(), but it allows the
  42.                     screen to be updated with incoming characters for the
  43.                     duration of the delay.  Delays can be used to wait for a
  44.                     prompt, etc.
  45.      dos();         Gives you access to DOS from within a Telix script. 
  46.                     'Access to DOS' means you can carry out a simple DOS
  47.                     command, such as COPY, DEL, etc., or you can even run
  48.                     another program if necessary.  The command must be
  49.                     placed between double quotes.  Examples:
  50.                       dos("DEL TEST.FIL"); ...or... dos("123.EXE");
  51.      goto <label>   A script or program normally runs from top to bottom, or
  52.                     from the first statement to the last.  To change this,
  53.                     and skip immediately to another section of the script,
  54.                     you use 'goto's.
  55.      hangup();      Breaks the connection by hanging up.
  56.      return();      End the current 'function' right where we are, and
  57.                     return to the 'caller'.  The 'caller' depends on where
  58.                     the return() is found.  If you return() from the main()
  59.                     function that all scripts start at, then you return to
  60.                     the calling script (The Liberator, etc.) or to Telix
  61.  
  62.  
  63.      The  L i b e r a t o r  v2.31                         SALT.DOC - Page 2
  64.  
  65.  
  66.  
  67.                     terminal mode.  The Liberator tests any value you
  68.                     return() from your script's main() function.
  69.      waitfor();     Wait for some text to come in from the BBS, or until a
  70.                     specified number of seconds elapses.  Combined with
  71.                     cputs(), this is a very useful function and can automate
  72.                     many tasks.
  73.  
  74.      Two other useful functions are:
  75.  
  76.      send();        Send a file to the BBS (upload)
  77.      receive();     Receive a file from the BBS (download)
  78.  
  79.      You can write many useful scripts using just these functions.  However,
  80.      your scripts wouldn't be capable of making any intelligent decisions
  81.      using just the above... For example, waitfor() allows you to wait for a
  82.      specified number of seconds for a certain message or prompt to come in
  83.      from the BBS; but what if the message doesn't come in?  You don't want
  84.      to answer a question if the question hasn't even been asked, so you
  85.      must have some way to test whether the text came in or not.  This is
  86.      where these two statements come into play:
  87.  
  88.      if()       Tests whether something is TRUE (successful) or FALSE
  89.                 (unsuccessful).
  90.      while()    Does something 'while' a certain condition is TRUE.
  91.  
  92.      What's all this about TRUE and FALSE?  How do these things 'test'
  93.      whether something is successful (TRUE) or unsuccessful (FALSE)?  There
  94.      is just a simple rule that they follow, which says that: "TRUE is
  95.      anything that is not zero".  The number 1 is TRUE, since it is not
  96.      zero, the letter 'A' must be TRUE since it is not zero... 1 + 1 (one
  97.      plus one) is TRUE, since it's end result is not zero, etc.  "FALSE is
  98.      anything that does end up to be zero"... 0 itself is FALSE, 1 - 1 (one
  99.      minus one) is FALSE since its end result is zero.
  100.  
  101.      This doesn't have to make sense... (and it certainly didn't for me at
  102.      first) that's just the way it is.  Anything that results in a zero
  103.      value is considered FALSE, anything that results in a non-zero value is
  104.      considered TRUE.  If something is FALSE, it is also known as unsuccess-
  105.      ful, or 'not' successful.  'Not' is used in SALT to refer to something
  106.      that is not TRUE: if it's "not TRUE", it must be FALSE, or zero.  I'm
  107.      attempting to burn this into your memory since it is used all over the
  108.      place in SALT and is important to pick up.  The true/false rule makes
  109.      scripts 'smart' enough to carry out meaningful decisions.  Almost
  110.      everything in SALT evaluates to TRUE or FALSE and can be tested with
  111.      if() and while().  Just using TRUE and FALSE was enough to create The
  112.      Liberator, and many of the other programs you use.
  113.  
  114.      If I had some money, how much do I have?  I have TRUE amount of money
  115.      (it must be TRUE since it isn't zero...).  To test the value in SALT, I
  116.      could use:
  117.  
  118.      if (money)
  119.  
  120.  
  121.  
  122.      The  L i b e r a t o r  v2.31                         SALT.DOC - Page 3
  123.  
  124.  
  125.  
  126.      ...which is the same as saying "if money is TRUE"...  Of course, it
  127.      wouldn't do much good just to know this unless I was going to do
  128.      something with the information, like this:
  129.  
  130.      if (money)
  131.       spend();
  132.  
  133.      This is how if() operates.  'If' whatever is between the brackets ends
  134.      up to be TRUE (not zero), then the next statement (up to the first ;)
  135.      is carried out: spend(); in this case.  Then we move happily along (by
  136.      the way, scripts execute from top to bottom, unless told otherwise). 
  137.      If whatever is between if()'s brackets evaluates to FALSE ('money'
  138.      would be FALSE if it was equal to zero) then the statement immediately
  139.      following the if() is *skipped*.  [Don't try to compile these ex-
  140.      amples... they're just nonsense used for demonstration.  Some usable
  141.      examples are given later.]
  142.  
  143.      if (this_is_TRUE)
  144.       then_do_this();
  145.  
  146.      The next line following an if() or while() is normally indented to show
  147.      that it may not get executed if the result is FALSE, and depends on the
  148.      if().  [Note that the SALT compiler doesn't care whether you indent or
  149.      not... in fact you could place an entire SALT script all on one line an
  150.      it will compile just fine.  Indending, and placing statements on
  151.      different lines is done solely for the benefit of people who read the
  152.      script.  It makes scripts easier to follow and debug.]
  153.  
  154.      Note also that the if() is not followed by a semicolon.  This is
  155.      because if() executes the next statement UP TO the first semicolon.  If
  156.      you use if(); then the semicolon is found immediately, and the if is
  157.      useless.  The SALT script compiler (CS.EXE) gives a warning if you
  158.      specify if(); or while(); like this, with no statement to execute
  159.      before the semicolon.
  160.  
  161.      While() works in the same way as if(), but instead of only executing
  162.      the next statement once, then moving along, it keeps running it over
  163.      and over again until whatever is between the brackets ends up to be
  164.      FALSE (or until we hit a 'break;' statement... which 'breaks' out of
  165.      while() 'loops').  Since it runs the next statement more than once,
  166.      while() is said to cause a 'loop' (you needn't remember this... it's
  167.      just a programming term).  For example, just spend()ing ONCE is no fun
  168.      while() we still have some money left, so:
  169.  
  170.      while (money)  // while money is TRUE, or non-zero
  171.       spend();      // spend() some, then go back and check
  172.                     // again in the while()
  173.      // once the while() is FALSE, (when money is equal to zero), then
  174.      // we exit the 'loop' and continue with any following statements
  175.  
  176.      You could also reverse this by using the word 'not'.  This would be an
  177.      appropriate while() loop to execute after the above spend()ing spree:
  178.  
  179.  
  180.  
  181.      The  L i b e r a t o r  v2.31                         SALT.DOC - Page 4
  182.  
  183.  
  184.  
  185.      while (not money)  // while money is 'not' TRUE (not TRUE is 0...FALSE)
  186.       work();           // go to work, then check again
  187.  
  188.      Now, I suppose you're wondering where all this is leading to... 
  189.      Believe it or not, if you understand the above it's only a matter of
  190.      time until you can write your own Liberator.  There isn't much more to
  191.      The Liberator than 'if this, do that, else do this'... 'while this, do
  192.      that', etc.  This is how all programs work.  Everything must be
  193.      planned for and tested with statements like if() and while().  Since
  194.      computers basically have the intelligence of lightbulbs... making a
  195.      program appear 'smart' is a lot of work, and may require hundreds of
  196.      if/while's--each testing a different condition which you must an-
  197.      ticipate ahead of time.  If you don't anticipate something, and if that
  198.      something happens, the computer will not automatically handle it for
  199.      you.  Computers know absolutely nothing about what task is actually
  200.      going on, and basically shouldn't be considered as 'intelligent' any
  201.      more than your toaster would be (okay... they're a *little* smarter
  202.      than toasters, but not much).
  203.  
  204.      What if you want to do two or more things if() something is TRUE (or
  205.      'not' TRUE)?  This is what those curly brackets are for:
  206.  
  207.      if (learning_SALT)  // if learning_SALT is TRUE
  208.       {                  // do whatever is between {}
  209.        read();
  210.        practice();
  211.       }
  212.  
  213.       or more appropriately:
  214.  
  215.      while (learning_SALT) // while learning_SALT is TRUE
  216.       {                    // do whatever is between {}
  217.        read();
  218.        practice();
  219.        experiment();
  220.       }
  221.      // once learning_SALT is false, the script continues here
  222.  
  223.      Now for some useful stuff to put between all these brackets.  The
  224.      functions listed at the beginning of this document will replace the
  225.      dummy functions I demonstrated with in actual scripts.  Don't panic,
  226.      but I want you to take a look in the SALT manual just for a second or
  227.      two.  If you don't have the manual printed out, you can pretty well
  228.      forget learning anything useful in SALT, unless you have an incredible
  229.      memory, or are multitasking, etc. and can easily browse the manual on
  230.      disk while viewing your script... While programming any script, it is
  231.      essential to be able to quickly check the syntax (format) and 'return
  232.      values' of functions.
  233.  
  234.      Look up waitfor() (all functions are listed alphabetically) and check
  235.      the 'Summary':
  236.  
  237.      waitfor (str <waitstr>, int <timeout>);
  238.  
  239.  
  240.      The  L i b e r a t o r  v2.31                         SALT.DOC - Page 5
  241.  
  242.  
  243.  
  244.  
  245.      This is not actually how you use the function.  You don't type in 'str
  246.      <waitstr>', etc.  These items are used as placeholders, to show you
  247.      what is expected, and where it is expected (commas always separate
  248.      arguments).  'str' refers to a 'string' (a bunch of letter, numbers,
  249.      symbols: a sentence) 'int' is an 'integer' (a number without a decimal
  250.      point: 1, -5, 10, 5000, etc).  The angle brackets surround <descrip-
  251.      tions>, to give you some idea what the 'str' (string) or 'int'
  252.      (integer) is used for.  Above, 'str <waitstr>' would be replaced with
  253.      the string (text) you want to wait for.  Strings must be enclosed in
  254.      double quotes:
  255.  
  256.      "This is a string of text that could replace str <waitstr>."
  257.  
  258.      <timeout> would be replaced with the number of seconds you want to wait
  259.      before 'timing out' (giving up).
  260.  
  261.      E.g.  waitfor("First name?", 10); // wait 10 seconds for "First name?"
  262.  
  263.      Also, check what waitfor() has to say under 'Return Value'.   As you'll
  264.      see, it 'returns' TRUE if the string is found, and FALSE if it isn't
  265.      found... which makes it very convenient to test with an if() or
  266.      while().  Remember, if() and while() test the END RESULT of whatever is
  267.      between their brackets, and if you stick a function such as waitfor()
  268.      there, then the end result is the 'return value' of waitfor().  The
  269.      'return value' is always the end result of a function.  Don't worry
  270.      about how it actually 'returns' this value, or even what a return value
  271.      is.  For now, just accept that most functions have return values that
  272.      can be tested with if() or while():
  273.  
  274.      if ( waitfor("First name?", 10) )
  275.       cputs("John Smith^M");
  276.  
  277.      The above may look complex, but it's really not.  The outer set of
  278.      brackets go with the if(), the inner go with the waitfor().  '^M' (two
  279.      characters, ^ and M) signifies Ctrl-M which is a Carriage Return or the
  280.      same as hitting <Return> or <Enter>.  If any of your 'strings' don't
  281.      get <Enter>ed in your scripts, add ^M to the end of the string, before
  282.      the closing quote (").
  283.  
  284.      Is this too easy?  Now, what is stopping you from applying what you
  285.      know about waitfor(), and the SALT manual, to the other SALT functions
  286.      I pointed out at the beginning?  Nothing at all... that's the whole
  287.      idea.  If you understand the above, and understand what purpose looking
  288.      up a function in the SALT manual serves, then there really isn't much
  289.      more you need to know about SALT.  It will only be a matter of time
  290.      until you memorize waitfor()... then cputs()... and so on until you can
  291.      create SALT scripts in your sleep.  The only complicated part of
  292.      programming in SALT is trying to keep all the arguments straight (does
  293.      int <timeout> come first, or str <waitstr> in waitfor()... etc).  This
  294.      is why I said it will be almost impossible to get anywhere in SALT
  295.      without instant access to the SALT manual.  After over a year of
  296.      constant SALT programming, I still refer to the SALT manual frequently,
  297.  
  298.  
  299.      The  L i b e r a t o r  v2.31                         SALT.DOC - Page 6
  300.  
  301.  
  302.  
  303.      just to check what goes where, and what is returned.
  304.  
  305.      EXAMPLES:
  306.  
  307.      Many useful tasks can be carried out by simply waitingfor() a question
  308.      or message, and cputs()ing the reply or carrying out some other
  309.      function, such as receive()ing files, or opening a capture() file, etc. 
  310.      You needn't use the track()/track_hit() functions, demonstrated in the
  311.      logon scripts, unless you absolutely have to track more than one prompt
  312.      at once.
  313.  
  314.      Here's an example how to use waitfor() effectively:
  315.  
  316.      main()
  317.      {
  318.       if (not waitfor("First name?", 10))
  319.        goto ERROR;
  320.       cputs("Your Name^M");
  321.  
  322.       // this type of thing can handle many tasks.  It means: 'if
  323.       // "First name?" DOESN'T come in within 10 seconds, jump down
  324.       // to the label ERROR below.  Otherwise put the string "Your
  325.       // Name^M" out the comm. port' (send it to the BBS).  Remember, 'not'
  326.       // means 'not TRUE' (FALSE), which is what waitfor() returns if
  327.       // <waitstr> is not found.
  328.  
  329.       // ... Continue on here with the same type of thing for the next
  330.       // question or operation...  You can handle just about anything
  331.       // with something like the above.  Replace the cputs() with what-
  332.       // ever you want to do.
  333.  
  334.       // ...
  335.  
  336.       if (waitfor("Command?", 10))  // logon complete?
  337.        return;                      // end the script here to avoid ERROR:
  338.  
  339.       ERROR:                        // labels used by 'goto's end with
  340.                                     //  a colon (:)
  341.        hangup();                    // hangup() the modem
  342.      }
  343.  
  344.      I created the script below for use on a local BBS, using a few of the
  345.      functions outlined at the beginning.  The script OPENs Mark Herring's
  346.      update door, hits a key at the end of each page while() the news is
  347.      being displayed, then selects and downloads my new copy of Deluxe (note
  348.      that you must be a registered Deluxe user to take advantage of the
  349.      update door, so please don't ask your Sysop for access if you are not a
  350.      registered Deluxe user).  Once compiled, I put the scripts' name in
  351.      Custom Command 1 of a Liberator Command File (e.g. @SPUD-DL), and have
  352.      the whole process carried out automatically--The Liberator does the
  353.      dialing/logon/logoff, and SPUD-DL handles the download:
  354.  
  355.  
  356.  
  357.  
  358.      The  L i b e r a t o r  v2.31                         SALT.DOC - Page 7
  359.  
  360.  
  361.  
  362.      ///////////////////////// SPUD-DL.SLT ///////////////////////////////
  363.      main()
  364.      {
  365.       cputs("OPEN 48^M");  // open door 48; replace w/proper door# for
  366.                            // your BBS
  367.       // translation: put the string "OPEN 48<Enter>" out the comm.
  368.       // port (same as typing it manually online).  Note the double quotes
  369.       // around OPEN 48^M, which must always surround strings.
  370.  
  371.       if (not waitfor("Deluxe Update Door", 120))
  372.        return(0);
  373.  
  374.       // translation: wait 120 seconds for the string "Deluxe
  375.       // Update Door" to come in from the BBS.  If it doesn't come in,
  376.       // return() a 0 to 'the caller' (if called from a Custom Command, 
  377.       // 'the caller' is The Liberator).  You can break it down to
  378.       // three SALT functions: if(), waitfor(), and return().  A
  379.       // return() from main() always ends the script at that point.
  380.  
  381.       while (waitfor("Press any key to continue...", 8))
  382.        cputs("^M");
  383.  
  384.       // translation:  wait 8 seconds for the string "Press any key to
  385.       // continue..." to come in, and 'while' the string keeps coming
  386.       // in, put an <Enter> (^M) out the communications port.  This
  387.       // can also be broken down to three functions: while(),
  388.       // waitfor(), cputs().  When 8 seconds go by without receiving
  389.       // the string, waitfor() will return FALSE (zero), thus ending the
  390.       // while() loop and continuing below.
  391.       
  392.       cputs("ALL^M"); // select ALL files for downloading (Door option)
  393.       delay_scr(20);  // delay for 20/10th's of a second, or 2 seconds
  394.       cputs("DOWNLOAD^M"); // send the door command to start the download
  395.  
  396.       if (waitfor("Begin your Zmodem download now...", 200))
  397.        receive('Z', "");
  398.  
  399.       // if the prompt "Begin your Zmodem download now..." comes in 
  400.       // within 200 seconds, then we start the download with the
  401.       // receive().  Otherwise we ignore the receive and continue
  402.       // below.  See the SALT manual for send/receive protocol
  403.       // letters.  Also note that the Zmodem protocol passes the
  404.       // filename (the BBS sends it with the file), so we don't have 
  405.       // to specify it in the receive() function--hence the "" where 
  406.       // the filename should be.  Receive() continues below when the
  407.       // download completes...
  408.  
  409.       waitfor("Command? ", 10); // pause for 10 seconds or until prompt
  410.       cputs("QUIT^M");          // then exit the door and...
  411.       waitfor("Command? ", 120);// waitfor PCBoard prompt to let The
  412.                                 // Liberator continue.
  413.      }
  414.      /////////////////////////////////////////////////////////////////
  415.  
  416.  
  417.      The  L i b e r a t o r  v2.31                         SALT.DOC - Page 8
  418.  
  419.  
  420.  
  421.  
  422.      The script above is included with The Liberator, so you needn't type it
  423.      in if you have an update door on your BBS and want to make use of it. 
  424.      Of course, you should change the door number in the "OPEN 48" to the
  425.      correct door on your BBS.  Simply type OPEN manually at a PCBoard
  426.      prompt to view available doors and see if your BBS has a Deluxe update
  427.      door.  You must have registered Mark Herring's Shareware reader, and
  428.      have a Deluxe serial number before making use of the door.  If the door
  429.      doesn't let you in, leave a C)omment to your Sysop with your Deluxe
  430.      serial number.
  431.  
  432.      I called the script SPUD-DL.SLT, for SParky (Mark Herring's nickname)
  433.      Update Door-DownLoad script.  All scripts, as I'm sure you are aware,
  434.      must be compiled before use with the 'CS.EXE' (Compile Script) program. 
  435.      Type 'CS SPUD-DL' to compile this one.
  436.  
  437.      You can use the above techniques to automate just about any job
  438.      (waitfor a prompt, if not found 'goto' somewhere else, or 'return',
  439.      otherwise enter the response).  I hope that if you are confused by any
  440.      of the above, that you'll take the time to review it and experiment
  441.      with some of the functions listed.  Learning the above basics of SALT
  442.      will give you considerably more enjoyment from Telix.
  443.  
  444.      Another Telix automator allows you to create scripts using something
  445.      like the above limited functions, but implements it so that the scripts
  446.      can only be interpreted by the automator itself and are useless to
  447.      Telix.  The syntax of the functions is different (dropping a bracket
  448.      here, adding a colon there), but just as time-consuming as learning the
  449.      actual SALT functions, in my opinion.  I think you're better off
  450.      spending your time gaining some control over SALT itself, so that you
  451.      are not dependant on The Liberator to run your scripts for you.  This
  452.      gives you the chance to automate tasks on BBS's that The Liberator
  453.      doesn't support, plus gives you more use of Telix itelf.
  454.  
  455.      For PCBoard BBS scripts though, you might as well plug the scripts you
  456.      create into a Custom Command and take advantage of The Liberator's
  457.      logon/logoff, dialing delay, Master, etc.  Having The Liberator execute
  458.      other SALT scripts is very simple.  See the section on Custom Commands
  459.      in LIBERATE.DOC for more information.
  460.  
  461.      If you absolutely have to waitfor() more than one prompt at one time,
  462.      you must use the track()/track_hit() functions, which are demonstrated
  463.      in PCBOARD.SLT and other logon scripts.  However, if possible start
  464.      with only the functions pointed out above, to avoid getting over-
  465.      whelmed.  There are quite a few functions in SALT, and I still keep the
  466.      manual within arm's length to look up functions I don't use very
  467.      often.  You truly won't get anywhere in SALT, without using the SALT
  468.      manual, unless you can somehow memorize the syntax/return values for
  469.      every function you use.  Keep the manual handy for reference, now that
  470.      you know how to use it.  Look up functions for reference when you need
  471.      them.
  472.  
  473.      One thing I'd also like to demonstrate, is how to define your own
  474.  
  475.  
  476.      The  L i b e r a t o r  v2.31                         SALT.DOC - Page 9
  477.  
  478.  
  479.  
  480.      'functions' in SALT.  It is almost so easy that it's not worth
  481.      explaining, since all you have to do is think up a name, and stick the
  482.      function in your script, just as you create the main() function.  The
  483.      reason I want to demonstrate functions is to save you the inevitable
  484.      frustration of forgetting to put a ^M after your string, within
  485.      cputs().  To avoid having to specify ^M for each string, we simply
  486.      create a new cputs() function:
  487.  
  488.      ///////////////////// Start of script ///////////////////////////
  489.      main()
  490.      {
  491.       cputs_cr("Will <Enter> be sent after this string?");
  492.      }
  493.  
  494.      cputs_cr(str string)
  495.      {
  496.       cputs(string);
  497.       cputs("^M");   // Yes, cputs_cr() never forgets the ^M...
  498.      }
  499.      ////////////////////// End of script ////////////////////////////
  500.  
  501.      The above is one script consisting of two separate functions: main()
  502.      and cputs_cr() (cputs with a CR or carriage return).  You could call
  503.      cputs_cr() 'knurts()' if you wanted to... but normally we try to make
  504.      the name remind what the function does.  Cputs_cr() accepts 1 str
  505.      (string) and chooses to call it 'string'.  You could also call 'string'
  506.      anything you wanted to:
  507.  
  508.      cputs_cr(str salt_is_easy)
  509.      {
  510.       cputs(salt_is_easy);
  511.       cputs("^M");
  512.      }
  513.  
  514.      Once you stick cputs_cr() in any of your Telix scripts, you can then
  515.      use it just as you would cputs!  If you wanted to pause the entry of
  516.      'string' for certain time before cputs()ing it, you could also pass a
  517.      delay to cputs_cr() like so:
  518.  
  519.      main()
  520.      {
  521.       cputs_cr("This is a string", 5);
  522.      }
  523.      cputs_cr(str string, int delay_time)
  524.      {
  525.       delay_scr(delay_time);  // delay_scr() pauses the script
  526.       cputs(string);
  527.       cputs("^M");
  528.      }
  529.  
  530.      Using functions() can really cut down on your typing, and can make
  531.      scripts much easier to work with -- and more reliable.
  532.  
  533.  
  534.  
  535.      The  L i b e r a t o r  v2.31                        SALT.DOC - Page 10
  536.  
  537.  
  538.  
  539.      Before coming to a close, there's also one other item, that while it
  540.      wasn't used in any of the scripts demonstrated here, it is used in the
  541.      logon scripts provided with Telix and can be fairly confusing to
  542.      beginners.  What I'm referring to the equality test ==, or two equals
  543.      signs.  Why use two instead of just one?  Well, in SALT one equal sign
  544.      is used to actually ASSIGN a value to a specific item.  If you wanted
  545.      to set the 'variable' stat to the number 10, you would use:
  546.  
  547.          stat = 10;
  548.  
  549.      To *test* whether stat was EQUAL TO the number 10, you use two equals
  550.      signs:
  551.  
  552.          if (stat == 10)
  553.           prints("This is printed if stat is equal to 10");
  554.  
  555.      If you used 'if (stat = 10)' then Telix would actually ASSIGN 10 to the
  556.      variable stat, then of course the if() would be TRUE since 10 is a TRUE
  557.      value (non zero).  This is one to watch for in your scripts.  Telix
  558.      doesn't give a warning if you use the wrong number of equals signs,
  559.      since you may have a good reason for one or two in any situation... it
  560.      assumes you know what you're doing.  If something is getting carried
  561.      out when it shouldn't, first check for a semicolon following the if();
  562.      or while(); and if that's not the problem see if you inadvertanly used
  563.      the assigment operator (=) instead of the equality test (==).
  564.  
  565.      That's it for now.  I know you probably still have many questions, and
  566.      I hope to expand this tutor in the future...  but I hope it was
  567.      informative and allows you to make some use of Telix SALT!
  568.  
  569.